#include <iostream>
#include <vector>

using namespace std;

typedef vector<unsigned int> VECTOR_UINT;

int main(void)
{
    unsigned int max_num;

    while((cin>>max_num) && (max_num != 0))
    {
        unsigned int i, j;
        VECTOR_UINT prime_numbers;

        for(i = 2; i <= max_num; i++)
        {
            bool is_prime_number = true;

            for(j = 0;
                (j < prime_numbers.size()) && (prime_numbers[j]*prime_numbers[j] <= i);
                j++)
            {
                if ((i % prime_numbers[j]) == 0)
                {
                    is_prime_number = false;
                    break;
                }
            }

            if (is_prime_number)
            {
                // i is a prime number
                prime_numbers.push_back(i);
            }
        }

        for(i = 0, j = 0; i < prime_numbers.size(); i++)
        {
            cout<<prime_numbers[i]<<(((++j % 10) == 0)?"\n":", ");
        }
    }

    return 0;
}

